<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
</head>

<body>
    <div id="app">
        <h1>简单计算器</h1>
        <div>
            <span>数值A：</span>
            <span>
          <input type="text" v-model="a" v-on:keyup.delete="clear" />
        </span>
        </div>
        <div>
            <span>数值B:</span>
            <span>
          <input
            type="text"
            v-model="b"
            v-on:keyup.delete="clear1"
            v-on:keyup.enter="handle"
          />
        </span>
        </div>
        <div>
            <button v-on:click="handle">计算</button>
        </div>
        <div>
            <span>计算结果：</span>
            <span v-text="result"></span>
        </div>
    </div>

    <script src="./vue.js"></script>
    <script>
        var vm = new Vue({
            el: "#app",
            data: {
                a: "",
                b: "",
                result: "",
            },
            methods: {
                handle: function() {
                    //实现计算逻辑
                    this.result = parseInt(this.a) + parseInt(this.b);
                    //获得的数据是字符串，但是不要字符串拼接，获取整数parseInt()
                },
                clear: function() {
                    this.a = "";
                },
                clear1: function() {
                    this.b = "";
                },
            },
        });
    </script>
</body>

</html>